package com.jwsoft.manager.core.dao.service.impl;

import cn.hutool.core.convert.Convert;
import com.alicp.jetcache.anno.CacheType;
import com.alicp.jetcache.anno.Cached;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jwsoft.manager.common.constant.EduCache;
import com.jwsoft.manager.common.vo.eduFormSpecial.EduFormSpecialQueryVO;
import com.jwsoft.manager.common.vo.eduFormSpecial.EduFormSpecialVO;
import com.jwsoft.manager.core.dao.model.EduFormSpecial;
import com.jwsoft.manager.core.dao.mapper.EduFormSpecialMapper;
import com.jwsoft.manager.core.dao.service.EduFormSpecialService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 特殊通道表服务实现类
 *
 * @author wangtao
 * @since 2022-12-06
 */
@Service
public class EduFormSpecialServiceImpl extends ServiceImpl<EduFormSpecialMapper, EduFormSpecial> implements EduFormSpecialService {
    @Override
    public List<EduFormSpecialVO> getList(EduFormSpecialQueryVO vo){
        return  baseMapper.getList(vo);
    }

    @Override
    public List<EduFormSpecialVO> getBrochureSpecialList(EduFormSpecialQueryVO vo){
        return  baseMapper.getBrochureSpecialList(vo);
    }

    @Override
    public EduFormSpecialVO getBySmallValue(EduFormSpecialQueryVO queryVO) {
        if (StringUtils.isBlank(queryVO.getSmallClassValue())) {
            return null;
        }
        QueryWrapper<EduFormSpecial> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(EduFormSpecial::getYear, queryVO.getYear())
                .eq(StringUtils.isNotBlank(queryVO.getBigClassValue()), EduFormSpecial::getBigClassValue, queryVO.getBigClassValue())
                .eq(EduFormSpecial::getSmallClassValue, queryVO.getSmallClassValue())
                .eq(StringUtils.isNotBlank(queryVO.getAreaCode()), EduFormSpecial::getAreaCode, queryVO.getAreaCode());
        List<EduFormSpecial> list = this.list(queryWrapper);
        if (!CollectionUtils.isEmpty(list)) {
            return Convert.convert(EduFormSpecialVO.class, list.get(0));
        }
        return null;
    }


}
